import { Opt } from '__com/Opt.js'
import ruleOpt from '@/option/rule.js'
import cityOpt from '@/option/city.js'
import apiMgr from '../../biz/index'
export class editOpt extends Opt {
  constructor(fun) {
    super(fun)
  }

  create() {
    return [
      {
        placeholder: '项目信息',
        text: {
          className: 'info-label-title'
        }
      },
      {
        title: '项目名称',
        key: 'tenantName',
        placeholder: '请输入项目名称',
        input: {
          maxlength: 20
        },
        rules: [ruleOpt.required('项目名称不能为空')]
      },
      {
        title: '合同主体',
        key: 'companyId',
        load: (o) => {
          apiMgr.getSysCompanyForWeb().then((res) => {
            console.log(res, '111')
            o.select.options = res
          })
        },
        select: {
          options: []
        },
        change: (val) => {
          console.log(val, '项目主体')
          this.chooseCompanyName(val.editValue)
        }
        // rules: [ruleOpt.required('角色类型不能为空')]
      },
      {
        title: '所属人手机号码',
        key: 'belongUserPhone',
        group: [
          {
            key: 'belongUserPhone',
            col: 20,
            placeholder: '请输入所属人手机号码',
            input: {
              maxlength: 11
            }
          },
          {
            col: 4,
            button: {
              title: '验证手机号码',
              click: (val) => {
                this.checkPhone()
              }
            }
          }
        ],
        rules: [ruleOpt.phone()]
      },
      {
        title: '确认手机号',
        key: 'phoneVerify',
        disabled: true,
        col: 20,
        input: {
          maxlength: 11
        },
        rules: [ruleOpt.required('确认手机号不能为空')]
      },
      {
        title: '所属人姓名',
        key: 'belongUserName',
        placeholder: '请输入所属人姓名',
        input: {
          maxlength: 20
        },
        rules: [ruleOpt.required('所属人姓名不能为空')]
      },

      cityOpt.cityCascader(
        {
          title: '所属城市',
          key: 'peopleCity',
          changeOnSelect: false,
          placeholder: this.onShowCheckCity(),
          change: (v) => {
            if (v.editValue.length) {
              this.chooseCity(v.editValue)
            } else {
            }
          },
          rules: [
            {
              type: 'array',
              required: true,
              message: '所属城市不能为空',
              trigger: 'blur'
            }
          ]
        },
        3
      ),
      {
        placeholder: '项目有效期',
        text: {
          className: 'info-label-title'
        }
      },
      {
        title: '开始时间',
        key: 'effectStartDate',
        placeholder: '请选择开始时间',
        xl: 4,
        date: {
          type: 'date',
          format: 'yyyy-MM-dd',
          disabled: (date) => {
            return date && date.valueOf() < Date.now() - 86400000
          }
        },
        change: (val) => {
          this.dataChange()
        },
        rules: [ruleOpt.required('请选择开始时间')]
      },
      {
        title: '结束时间',
        key: 'effectEndDate',
        placeholder: '请选择结束时间',
        xl: 4,
        date: {
          type: 'date',
          format: 'yyyy-MM-dd',
          disabled: (date) => {
            return date && date.valueOf() < Date.now() - 86400000
          }
        },
        change: (val) => {
          this.dataChange()
        },
        rules: [ruleOpt.required('请选择结束时间')]
      },

      {
        title: '有效天数',
        key: 'day',
        group: [
          {
            key: 'day',
            col: 2,
            text: {}
          },
          {
            placeholder: '天',
            col: 1,
            text: {}
          }
        ]
      },
      {
        placeholder: '功能包配置',
        text: {
          className: 'info-label-title'
        }
      }
    ]
  }
}

// export class dataOpt extends Opt {
//   constructor(fun) {
//     super(fun)
//   }

//   create() {
//     return [
//       {
//         title: '开始时间',
//         key: 'effectStartDate',
//         placeholder: '请选择开始时间',
//         xl: 4,
//         date: {
//           type: 'date',
//           format: 'yyyy-MM-dd',
//           disabled: (date) => {
//             return date && date.valueOf() < Date.now() - 86400000
//           }
//         },
//         change: (val) => {
//           this.dataChange()
//         },
//         rules: [ruleOpt.required('请选择开始时间')]
//       },
//       {
//         title: '结束时间',
//         key: 'effectEndDate',
//         placeholder: '请选择结束时间',
//         xl: 4,
//         date: {
//           type: 'date',
//           format: 'yyyy-MM-dd',
//           disabled: (date) => {
//             return date && date.valueOf() < Date.now() - 86400000
//           }
//         },
//         change: (val) => {
//           this.dataChange()
//         },
//         rules: [ruleOpt.required('请选择结束时间')]
//       },

//       {
//         title: '有效天数',
//         key: 'day',
//         group: [
//           {
//             key: 'day',
//             col: 1,
//             text: {}
//           },
//           {
//             placeholder: '天',
//             col: 1,
//             text: {}
//           }
//         ]
//       }
//     ]
//   }
// }

export class refuelingOpt extends Opt {
  constructor(fun) {
    super(fun)
  }

  create() {
    return [
      {
        placeholder: '加油包配置',
        text: {
          className: 'info-label-title'
        }
      },
      {
        title: '项目账号数',
        key: 'accountNumber',
        group: [
          {
            key: 'accountNumber',
            col: 10,
            input: {
              maxlength: 5
            }
          },
          {
            placeholder: '个',
            col: 1,
            text: {}
          }
        ],
        rules: [ruleOpt.required('请填写项目账号数'), ruleOpt.positiveInteger()]
      },
      {
        placeholder: '项目备注',
        text: {
          className: 'info-label-title'
        }
      },
      {
        title: '',
        key: 'remark',
        placeholder: '请输入项目备注',
        input: {
          type: 'textarea',

          showWordLimit: true,
          maxlength: 200,
          autosize: {
            minRows: 3,
            maxRows: 5
          }
        }
      }
    ]
  }
}
